iOS 6 Recipes by Hans-Eric Grönlund & Colin Francis & Shawn Grimes

iOS 6 Recipes by Hans-Eric Grönlund & Colin Francis & Shawn Grimes

Author:Hans-Eric Grönlund & Colin Francis & Shawn Grimes
Language: eng
Format: epub
ISBN: 9781430245995
Publisher: Apress


#import <UIKit/UIKit.h>

NSString * const TweetCellId = @"TweetCell";

@interface TweetCell : UITableViewCell

@property (strong, nonatomic)NSDictionary *tweetData;

@end

This cell type uses the standard look with a subtitle and a disclosure indicator. Make these changes to the initWithStyle:reuseIdentifier: method (in the TweetCell.m file):

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{

self = [super initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:reuseIdentifier];

if (self)

{

// Initialization code

self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

}

return self;

}

The cell updates its labels when it receives new tweet data. To accomplish that you’ll add a custom setter method for the tweetData property, like so:

-(void)setTweetData:(NSDictionary *)tweetData

{

_tweetData = tweetData;

// Update cell

NSDictionary *userData = [_tweetData objectForKey:@"user"];

self.textLabel.text = [userData objectForKey:@"name"];

self.detailTextLabel.text = [_tweetData objectForKey:@"text"];

}

Now, let’s complete the implementation of the Table View. Go back to TweetTableViewController.m and make the following changes:

//

// TweetTableViewController.m

// My Tweet Reader

//



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.